package io.gitee.xyuesheng.day09;

public class Consumer implements Runnable {
    private Factory factory;


    public Consumer(Factory factory) {
        this.factory = factory;
    }

    @Override
    public void run() {
        //每隔0-20ms，从工厂里面取一个产品
        while (true) {
            try {
                Thread.sleep((long) (Math.random() * 50));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            this.factory.get();

        }

    }
}
